package day5;

import org.junit.Test;

public class IntegerDemo {
    @Test
    public void test1() {
        // Integer integer = new Integer(4);
        Integer integer = 4;// 自动装箱，等价于：Integer integer = new Integer(4);
        int i = integer.intValue();
        int num = 3;
        num = num + 2;
        integer = integer + 2;// 自动拆箱integer.intValue()
        // integer.intValue() + 2 = 6
        // 得到int类型的6，又赋值给Integer类型，自动装箱

    }

    @Test
    public void test2() {
        String str1 = "23";
        int value1 = Integer.parseInt(str1);
        System.out.println(value1 + 1);// 24

        String str2 = "3.14";
        double value2 = Double.parseDouble(str2);
        System.out.println(value2 + 1);

        String str3 = "false";
        boolean value3 = Boolean.parseBoolean(str3);
        System.out.println(value3);
    }

    @Test
    public void test55() {
        String str = "23";
        System.out.println(str + 1);// 231

        Integer integer = new Integer(str);
        int i = integer.intValue();
    }
}
